package com.baizhi.homework;

import java.util.Objects;

public class News {
    private String title;
    private String author;
    private String details;

    public News() {
    }

    public News(String title, String author, String details) {
        this.title = title;
        this.author = author;
        this.details = details;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        News news = (News) o;
        return Objects.equals(title, news.title);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title, author, details);
    }


    @Override
    public String toString() {
        if(details.length()>15){
            details = details.substring(0, 15) + "...";
        }

        return "News{" +
                "title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", details='" + details + '\'' +
                '}';
    }
}
